<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="Generator" content="ECSHOP v2.7.3"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>会员登录_{{config('sys.siteName')}}</title>
    <meta name="Keywords" content=""/>
    <meta name="Description" content=""/>
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link type="text/css" rel="stylesheet" href="/home/default/css/cart.css"/>
    <link href="{{$temps_src}}/css/css.css" type="text/css" rel="stylesheet">
    <link type="text/css" rel="stylesheet" href="/home/default/css/BombboxLogin.css"/>
    <link type="text/css" rel="stylesheet" href="/home/default/css/logincommon.css"/>
    <link rel="stylesheet" href="/home/default/css/register.css"/>
    <link rel="stylesheet" href="/admin/css/xadmin.css">
    <script src="/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/admin/js/jquery.min.js"></script>
</head>
<body style="background:#fff;">
@include('home.default.header')
  
<div class="block">
    <div class="">
        <div id="content">
            <div class="login-newbg" style="background-image: url(/home/default/images/login_bg.jpg);"></div>
            <div class="content-layout">
                <div class="login-wrap">
                    <div class="logo-content">
                        <div class="login-others">
                            <h2 style="margin:30px auto;">会员登录</h2>
                            
                            <div class="person">
                                <form class="layui-form">
                                    <div class="layui-form-item">
                                    <label class="layui-form-label" >用户名</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="name" required lay-verify="required"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                 </div>
                                 <div class="layui-form-item">
                                    <label class="layui-form-label">密码</label>
                                    <div class="layui-input-block">
                                        <input type="password" name="password" required lay-verify="required"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div id="embed-captcha"></div>
                                    <p id="wait" class="show">正在加载验证码......</p>
                                    <p id="notice" class="hide" style="margin: 5px auto;">请先完成验证</p>
                                </div>
                                <div class="layui-form-item" style="margin-top: 40px;">
                                    <button id="embed-submit" class="layui-btn" style="width: 90px;" lay-filter="submit" lay-submit="">
                                        登   录
                                    </button>
                                </div>
                            </form>
                            </div>
                        </div>
                        <div id="login-footer-1" class="login-footer login-footer-1"><!--勾选协议-->
                            <p class="denglu" style="font-size: 16px;">
                                没有帐号?
                                <a style="font-size: 16px; color: #0e771e; text-decoration: none;" site="3" href="/register" id="parbox-toSocialAccountLogin"
                                   class="qt-c00BE6E statis site-change">
                                    去注册
                                </a></p></div>
                        <div class="clearfix"></div>
                    </div>
                </div>


            </div>

        </div>
    </div>
</div>
</div>
</div>
</div>
@include('home.default.footer')
</body>
<script>
    
    $(document).on('click', '.phonelogin', function () {
        $('.percent').hide();
        $('.person').show();
    })

</script>
<script src="/admin/js/gt.js"></script>
<script>
    var handlerEmbed = function (captchaObj) {
        $("#embed-submit").click(function (e) {
            var validate = captchaObj.getValidate();
            if (!validate) {
                $("#notice")[0].className = "show";
                setTimeout(function () {
                    $("#notice")[0].className = "hide";
                }, 2000);
                e.preventDefault();
            }
        });
        // 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
        captchaObj.appendTo("#embed-captcha");
        captchaObj.onReady(function () {
            $("#wait")[0].className = "hide";
        });
        // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
        captchaObj.onSuccess(function () {
            var result = captchaObj.getValidate();
            if(result){
                $("#captcha").val(1);
            }
            else{
                $("#captcha").val(0);
            }
        });
    };
    $.ajax({
        // 获取id，challenge，success（是否启用failback）
        url: "/admin/login/gt?t=" + (new Date()).getTime(), // 加随机数防止缓存
        type: "get",
        dataType: "json",
        success: function (data) {
            console.log(data);
            // 使用initGeetest接口
            // 参数1：配置参数
            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
            initGeetest({
                gt: data.gt,
                challenge: data.challenge,
                new_captcha: data.new_captcha,
                product: "embed", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                offline: !data.success,
                width:140
                // 表示用户后台检测极验服务器是否宕机，一般不需要关注

                // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
            }, handlerEmbed);
        }
    });

</script>
<script>
    initGeetest({
        // 省略配置参数
    }, function (captchaObj) {
        // 省略其他方法的调用

        captchaObj.onSuccess(function () {
            var result = captchaObj.getValidate();

            // ajax 伪代码，进行二次验证
            ajax('/api/gt-validate', {
                geetest_challenge: result.geetest_challenge,
                geetest_validate: result.geetest_validate,
                geetest_seccode: result.geetest_seccode,

                // 其他服务端需要的数据，比如登录时的用户名和密码
            }, function (data) {
                // 根据服务端二次验证的结果进行跳转等操作
            });
        });
    });
</script>
<script>layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;


            //监听提交
            form.on('submit(submit)',
                function(data) {

                    //发异步，把数据提交给php
                    $.ajax({
                        type:'POST',
                        url:'/dologin',
                        dataType:'json',
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        data:data.field,
                        success:function (data) {
                            if(data.status_code == 200){
                                layer.alert(data.res, {
                                        icon: 1,
                                        time:1500,
                                        end:function () {
                                            $('.wxpic img').attr('src', "/home/default/images/login_success.jpg");
                                            setInterval(function(){
                                                window.location.href = '/userinfo';
                                            },500)

                                        }
                                    },
                                );
                            }
                            else{
                                layer.alert(data.res, {
                                        icon: 5,
                                    },
                                    function() {
                                        //关闭当前frame
                                        xadmin.close();

                                        // 可以对父窗口进行刷新
                                        xadmin.father_reload();
                                    });
                            }

                        },
                        error:function () {

                        }

                    })

                    return false;
                });

        });</script>
